/* 
 * File:   quicksort.h
 * Author: gustavo
 *
 * Created on August 7, 2011, 2:38 AM
 */

#ifndef GQSORT_H
#define	GQSORT_H

#ifdef	__cplusplus
extern "C" {
#endif



    /**
     * Generic Quick Sort algorithm.
     * 
     * This function supports any data structure array
     * with a defined compare method.
     * 
     * @param base: a pointer to the first element of the array.
     * @param total_elements: number of elements in the array.
     * @param unit_size: size of data structure (bytes)
     * @param compare: a function that compare the elements e1 and e2.
     * The parameters e1 and e2 must be a pointer to the structure stored
     * in base vector.
     * if( e1 < e2 ) then returns a negative value.
     * if( e1 > e2 ) then returns a positive value.
     * if( e1 == e2 ) then returns 0.
     */
    void gqsort(void * base, long int total_size, long int unit_size,
            int (*compare)(void * e1, void * e2));

#ifdef	__cplusplus
}
#endif

#endif	/* QUICKSORT_H */

